name: Publish Docker Image

on:
  push:
    branches: ['main']

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      packages: write
      contents: read
    steps:
      - name: Check out the repo
        uses: actions/checkout@v4

      - name: Log in to Docker Hub
        uses: docker/login-action@v3
        with:
          registry: ${{ secrets.ARTIFACT_REGISTRY_URI }}
          username: ${{ secrets.ARTIFACT_REGISTRY_KEY }}
          password: ${{ secrets.ARTIFACT_REGISTRY_SECRET }}

      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}, latest